<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
		<meta name="apple-mobile-web-app-capable" content="yes"><!--删除默认的苹果工具栏和菜单栏-->
		<meta name="apple-mobile-web-app-status-bar-style" content="black" /><!--状态栏显示为黑色-->
		<meta name="format-detection" content="telephone=no" /><!--电话号码不被显示为拨号连接-->
		<title>融资融券交易终端</title>
		<link rel="stylesheet" href="<?php echo STATIC_SERVER; ?>/mobile/layer/layer.css" id="layui_layer_layercss"/>
		<link rel="stylesheet" href="<?php echo STATIC_SERVER; ?>/mobile/css/weui.css" />
		<link rel="stylesheet" href="<?php echo STATIC_SERVER; ?>/mobile/css/style.css" />
		<script src="<?php echo STATIC_SERVER; ?>/mobile/js/jquery-1.12.1.min.js"></script>
		<script src="<?php echo STATIC_SERVER; ?>/mobile/layer/layer.js"></script>
	</head>
	<body>
		<div class="xinsu-logs">
			<img class="xinsu-logo" src="<?php echo STATIC_SERVER; ?>/mobile/img/logo_01.png" />
			<form class="weui-cells_form xinsu-form" method="post">
				<input type="text" name="username" class="weui-input xinsu-input" value="" placeholder="请输入用户账号" />
				<input type="password" name="password" class="weui-input xinsu-input" value="" placeholder="请输入登录密码" />
				<input type="text" name="code" class="weui-input xinsu-input" style="width:40%" value=""  maxlength="4" placeholder="请输入验证码" />
				<img src="/user/verify" id="verify" onclick="refresh()" style="height:42px;margin-bottom:-15px;"/>
				<div class="xinsu-clear"></div>
				<button class="xinsu-but" type="submit">确定</button>
			</form>
		</div>
	</body>
	<script src="<?php echo STATIC_SERVER; ?>/mobile/js/jquery-1.12.1.min.js"></script>
	<script src="<?php echo STATIC_SERVER; ?>/mobile/layer/layer.js"></script>
	<script language='JavaScript' type="text/javascript">
		//登录
		$("form").submit(function(){
			var data = $(this).serialize();
			$.ajax({
				type:'post',  
				url : "/user/login",
				dataType : 'json',
				data : data,
				success : function(repones) {
					if (repones.status == 1 || repones.status == 2) {
						layer.msg('登录成功', {time: 800}, function(){
							location.href = "/stock";
						});
					} else {
						refresh();
						layer.msg(repones.msg);return false;
					}
				},
				error : function() {
					refresh();				
					layer.msg('加载数据失败，请重新加载');return false;
				}
			});
			return false;
		})
		
		//刷新验证码
		function refresh() {
			$('#verify').attr("src", "/user/verify?t=" + Math.random());
		}
	</script>
</html>
